package club.caihappy.store.controller;

import club.caihappy.store.entity.District;
import club.caihappy.store.service.IDistrictService;
import club.caihappy.store.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by DELL on 2022/3/17
 **/
@RequestMapping("districts")
@RestController
public class DistrictController extends BaseController {

    @Autowired
    private IDistrictService districtService;

    @RequestMapping({"/",""})
    public JsonResult<List<District>> getByParent(String parent) {
        List<District> parents = districtService.findByParent(parent);
        return new JsonResult<>(OK, parents);
    }
}
